<template>
  <div class="container">
    <h1>{{add}}</h1>
  </div>
</template>

<script>
export default {
  data() {
    return {
        // data:new Date(),
        datatime:new Date("2022-5-1"),
        // minutes:data.getMinutes(),
        sjc:'',
        tian:'',
        shi:'',
        fen:'',
        miao:'',
        add:''
    }
  },
  methods:{
      fun(){
          var data = new Date()
        this.sjc=this.datatime-data,
        console.log(this.sjc);
        this.tian=Math.floor(this.sjc/1000/60/60/24),
        this.shi=Math.floor(this.sjc/1000/60/60%24),
        this.fen=Math.floor(this.sjc/1000/60%60),
        this.miao=Math.floor(this.sjc/1000%60)
        this.add=`距离五一劳动节还有${this.tian}天${this.shi}时${this.fen}分${this.miao}秒`
        console.log(`距离五一劳动节还有${this.tian}天${this.shi}时${this.fen}分${this.miao}秒`);
      },
      time(){
          setInterval(this.fun,1000)
      }
  },
  created() {
    this.time();

  },
}
</script>

